<?php

class Db_Tables2_TRegion
{
	function __construct() {
		$this->dealers_db = Zend_Registry::get("dealers_db");
	}
	
	function GetCounties($cityId)
	{
		$result = array();
		
		$select = $this->dealers_db->select();
		$select->from("t_region", array("countyId", "countyName"));
		
		if($cityId)
		{
			$select->where("cityId = ?", $cityId);
		}
		
		$select->order("id ASC");
		
		$data = $this->dealers_db->fetchAll($select);
		
		if(!empty($data))
		{
			foreach($data as $d)
			{
				$result[] = array(
					'countyId' => $d['countyId'],
					'countyName' => $d['countyName']
					);
			}
		}
		
		return $result;
	}
}